$(function() {
		$('#alladd').click(function() {
			$('#leftselect option').remove().appendTo('#rightselect');
		});
		$('#allremove').click(function() {
			$('#rightselect option').remove().appendTo('#leftselect');
		});
		$('#add').click(function() {
			$('#leftselect option:selected').remove().appendTo('#rightselect');
		});
		$('#remove').click(function() {
			$('#rightselect option:selected').remove().appendTo('#leftselect');
		});
		$('#leftselect').dblclick(function() {
			$("option:selected", this).remove().appendTo('#rightselect');
		});
		$('#rightselect').dblclick(function() {
			$("option:selected", this).remove().appendTo('#leftselect');
		});
		$('#left_up')
				.click(
						function() {
							var index = $('#leftselect option').index(
									$('#leftselect option:selected:first'));
							var $recent = $('#leftselect option:eq(' + (index - 1) + ')');
							if (index > 0) {
								var $options = $('#leftselect option:selected')
										.remove();
								setTimeout(function() {
									$recent.before($options)
								}, 10);
							}
						});
		$('#left_down')
				.click(
						function() {
							var index = $('#leftselect option').index(
									$('#leftselect option:selected:last'));
							var len = $('#leftselect option').length - 1;
							var $recent = $('#leftselect option:eq(' + (index + 1) + ')');
							if (index < len) {
								var $options = $('#leftselect option:selected')
										.remove();
								setTimeout(function() {
									$recent.after($options)
								}, 10);
							}
						});
		$('#right_up')
				.click(
						function() {
							var index = $('#rightselect option').index(
									$('#rightselect option:selected:first'));
							var $recent = $('#rightselect option:eq(' + (index - 1) + ')');
							if (index > 0) {
								var $options = $('#rightselect option:selected')
										.remove();
								setTimeout(function() {
									$recent.before($options)
								}, 10);
							}
						});
		$('#right_down')
				.click(
						function() {
							var index = $('#rightselect option').index(
									$('#rightselect option:selected:last'));
							var len = $('#rightselect option').length - 1;
							var $recent = $('#rightselect option:eq(' + (index + 1) + ')');
							if (index < len) {
								var $options = $('#rightselect option:selected')
										.remove();
								setTimeout(function() {
									$recent.after($options)
								}, 10);
							}
						});
	});